<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../layui/css/layui.css"/>
	</head>
	<body style="padding: 30px 10px 10px 10px">
		<form class="layui-form" lay-filter="chanceDataFilter">
			<div class="layui-form-item">
				<label class="layui-form-label">创建人<i style="color: red;"> * </i></label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chCreator"  lay-verify="required" autocomplete="off" placeholder="请输入创建人!" class="layui-input"/>
				</div>
				<label class="layui-form-label">创建时间<i style="color: red;"> * </i></label>
				<div class="layui-input-inline" style="width: 30%;">
					<input disabled class="layui-input layui-disabled" type="text" name="chCreationdate" lay-verify="required|date" id='creationDate' lay-reqtext="!" autocomplete="off" placeholder="*必填项!" class="layui-input"/>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">任务接收者</label>
				<div class="layui-input-inline" style="width: 30%;">
					<input disabled class="layui-input layui-disabled" type="text" name="chRole" id='chRole'  autocomplete="off" placeholder="不写" class="layui-input" />
					
				</div>
				<label class="layui-form-label">指派时间</label>
				<div class="layui-input-inline" style="width: 30%;">					
					<input disabled class="layui-input layui-disabled" type="text" name="chAssigindate"  id='assiginDate' lay-reqtext="" autocomplete="off" placeholder="不写" class="layui-input"/>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">客户名称<i style="color: red;"> * </i></label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chName"  lay-verify="required" autocomplete="off" placeholder="请输入客户名称!" class="layui-input" />
					
					
				</div>
				<label class="layui-form-label">联系人<i style="color: red;"> * </i></label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chContacts" lay-verify="required" lay-reqtext="不能为空!" autocomplete="off" placeholder="请输入联系人!" class="layui-input"/>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">客户电话<i style="color: red;"> * </i></label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chPhone"  lay-verify="required|phone|number" autocomplete="off" placeholder="请输入联系电话!" class="layui-input" />
				</div>
			   <label class="layui-form-label">销售机会状态</label>
			   <div class="layui-input-inline" style="width: 30%;">
			     <select name="chState" >
			     
			       <option value="0" selected>未指派</option>
			      
			     </select>
			   </div>
			</div>
			<div class='layui-form-item'>
				<label class="layui-form-label">概要描述</label>
				<div class="layui-input-inline" style="width: 60%;">
					<!-- <input type="text" name="chDescribed" autocomplete="off" placeholder="请输入概要描述!" class="layui-input"/> -->
					<textarea placeholder="请输入概要描述!" class="layui-textarea" name="chDescribed"></textarea>
				</div>
			</div>
			<!-- 合作等级 -->
			
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit lay-filter="submitAddData"> 提交</button>
					<button type="reset" class="layui-btn layui-btn-primary"> 重置</button>
				</div>
			</div>
			
		</form>
	<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
	</body>
	<script>
		layui.use(['form','jquery','laydate'],function(){
			var form = layui.form
			var $ = layui.jquery
			var laydate = layui.laydate;
			// table.render();
			laydate.render({
				elem:'#creationDate'
			});
			laydate.render({
				elem:'#assiginDate'
			});
			form.on('submit(submitAddData)',function(AddData){
				AddData.field
				debugger
				$.ajax({
					url:'http://localhost:8080/chance/addChance',
					type:'POST',
					dataType:'JSON',
					data:AddData.field,
					success:function(backjson){
						parent.table.reload('salesManage');//现在在子页面，要在父页面刷新  要把table定义为全局变量
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
						// layer.msg('已添加' + AddData.field[2] )
						
					},//回调函数 
				});
				return false;//阻止form提交刷新
				// layer.msg('已添加' + AddData.field[2] )
			});
		  Date.prototype.format = function (format) {
		             var args = {
		                 "M+": this.getMonth() + 1,
		                 "d+": this.getDate(),
		                 "h+": this.getHours(),
		                 "m+": this.getMinutes(),
		                 "s+": this.getSeconds(),
		                 "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
		                 "S": this.getMilliseconds()
		             };
		             if (/(y+)/.test(format))
		                 format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
		             for (var i in args) {
		                 var n = args[i];
		                 if (new RegExp("(" + i + ")").test(format))
		                     format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
		             }
		             return format;
		         };
		  $("#creationDate").val(new Date().format("yyyy-MM-dd"))
		});
	</script>
</html>